package sk.robocup.dvanastyhrac.tactics;

import robocup.component.tactics.StateEvaluation;

/**
 * Created on 24.4.2009 at 14:17:18
 * @author gpan
 */
public class DefensiveInterceptOpponentState12 extends InterceptOpponentState12 {

    public DefensiveInterceptOpponentState12(StateEvaluation parent) {
        super(parent);
        this.state = STATES.INTERCEPT_OPPONENT;

    }

    @Override
    public boolean preCondition() {

        if (!this.checkPlayMode() || !this.getBall().isReliable() || this.getPlayer().canKick(getWorld().getBallRef()) || (this.getProphet().getFastestTeammateToBall() != null &&
                this.getProphet().getFastestTeammateToBall().isMe())) {
            return false;
        }

        // ako v normalnom intercept ale ked je lopta v nasej 16tke tak reagujem na vacsiu vzdialenost
        
        //ak som najblizsi k lopte tak bzim samozrejme
        if (this.getWorld().getClosestPlayerTo(this.getWorld().getTeammates(),
                this.getWorld().getBallRef().getPosition(), true).isMe() ) {
            return true;
        //nie som sice najblizsi k lopte ale lopta je v nasej sesnastke a som od nej vo vzdialenosti 15 takze idem
        } else if (this.getWorld().getBallRef().getDistance(this.getWorld().getSelfRef()) < 10 && this.getWorld().inOwnDangerArea(this.getWorld().getBallRef())) {
            return true;
        //nie som sice najblizsi a ani nie je lopta v sestnastke ale som pri nej velmi blizko takze idem
        } else if (this.getWorld().getBallRef().getDistance(this.getWorld().getSelfRef()) < 5) {
            return true;
        //mna sa to netyka som daleko velmi
        } else {
            return false;
        }
    }
}
